package cn.ac.siom.query.action;

import cn.ac.siom.query.service.ITab_orgService;
import cn.ac.siom.query.util.action.DefaultAction;
import cn.ac.siom.query.vo.Tab_org;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.sql.SQLException;
import java.util.List;

@Controller
@RequestMapping(value = "/home/*")
public class Tab_orgAction extends DefaultAction {
    @Resource
    private ITab_orgService tab_orgService;

    @RequestMapping(value = "tab_org_list")
    public void tab_org_Conference_list(HttpServletResponse response) {
        response.setHeader("Access-Control-Allow-Origin", "*");
        try {
            super.printObjectToList(response, "allTab_org", this.tab_orgService.list());
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


    @ResponseBody
    @RequestMapping(value="findNO_Tab_org", method= RequestMethod.GET,produces="application/json;charset=UTF-8")
    public List<Tab_org> findNO(Integer i_id) throws SQLException {
        System.out.println(i_id);
        List<Tab_org>  tab_org = (List<Tab_org>) this.tab_orgService.list_NO(i_id);
        for(Tab_org tab_Thes:tab_org) {
            System.out.println(tab_Thes.toString());
        }
        return tab_org;
    }


    @Override
    public String getText() {
        return null;
    }
}
